<ui:composition xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:fn="http://java.sun.com/jsp/jstl/functions"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets" template="/home.xhtml">
	<ui:define name="corpo">
	<h:outputScript></h:outputScript>
		<h:form prependId="false">
			<p:panel header="Administrar Tipo de consultas" style="background: #dbfbda;font-size:15px;min-height:700px;margin-top:10px;float:left;width:99%">
				<h:panelGroup style="float: left;width:250px;" layout="block">
					<ui:include src="menu.xhtml" />
				</h:panelGroup>
				<h:panelGroup layout="block" style="float:left">
				    	<p:dataTable var="tipo" value="#{manterAdministradorBean.administradorForm.tipoConsultas}" id="table_tipoConsulta" paginator="true" rows="15"  
				                 paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}" 
				                 paginatorPosition="bottom" style="width:700px">  
					  
				            <f:facet name="header">  
				                <h:outputText value="Tipo de Consultas Cadastradas" />
				            </f:facet>  
					        <p:column>  
					            <f:facet name="header">  
					                <h:outputText value="Tipo" />  
					            </f:facet>  
					            <h:outputText value="#{tipo.tipoConsulta}" />  
					        </p:column>  

					        <p:column>  
					            <f:facet name="header">  
					                <h:outputText value="Valor" />  
					            </f:facet>  
					            <h:outputText value="#{tipo.valorConsulta}">
					            	<f:convertNumber type="currency"/>
					            </h:outputText>  
					        </p:column>  

					        <p:column style="text-align: center">  
					            <f:facet name="header">  
					                <h:outputText value="Excluir" />  
					            </f:facet>  
					            <p:commandButton image="ui-icon ui-icon-trash" oncomplete="excluir.show()">
					            	<f:setPropertyActionListener target="#{manterTipoConsultaBean.tipoConsulta}" value="#{tipo}" />
					            </p:commandButton>  
					        </p:column>  
	
					        <p:column style="text-align: center">  
					            <f:facet name="header">  
					                <h:outputText value="Editar" />  
					            </f:facet>  
					            <p:commandButton image="ui-icon ui-icon-transferthick-e-w" oncomplete="editar.show()" update="pnl_edit">
					            	<f:setPropertyActionListener target="#{manterTipoConsultaBean.tipoConsulta}" value="#{tipo}" />					            	
					            </p:commandButton>
					        </p:column>  
					  
					  		<f:facet name="footer">
				                <p:commandButton value="Cadastrar" image="ui-icon ui-icon-circle-plus" style="position: relative; right: 290px;" oncomplete="cadastrar.show()" action="#{manterTipoConsultaBean.limparCampo}" update="pnl_cadastro" />
				            </f:facet>
					    </p:dataTable>
				</h:panelGroup>
			 
			</p:panel>
			
		</h:form>
		
		<ui:include src="modal_excluir_admin.xhtml">
			<ui:param name="bean" value="#{manterTipoConsultaBean}" />
			<ui:param name="metodo" value="excluir" />
			<ui:param name="idTabela" value="table_tipoConsulta" />
		</ui:include>
		
		<p:dialog header="Editar" widgetVar="editar" resizable="false" modal="true" width="450" showEffect="clip" hideEffect="fold">
			<h:form prependId="false">
				<h:panelGrid columns="2" cellpadding="2" cellspacing="0" id="pnl_edit">
					
					<h:panelGroup>
						<span class="campoObrigatorio">*</span>
						<h:outputLabel value="#{msg['display.label.tipoConsulta.nome']}" style="font-weight:bold" for="tipoConsulta" styleClass="fmt_label_form_cadastro" />
					</h:panelGroup>					
					<p:inputText value="#{manterTipoConsultaBean.tipoConsulta.tipoConsulta}" size="50" maxlength="50" label="tipo consulta" required="true" id="tipoConsulta" style="border: solid 1px #5FA03F;background-color: #FFF;" styleClass="fmt_input_form_cadastro" />					
					<h:outputText />
					<h:message for="tipoConsulta" id="msgTipoConsulta" styleClass="msg_erro_required"/>
					
					<h:panelGroup>
						<span class="campoObrigatorio">*</span>
						<h:outputLabel value="#{msg['display.label.tipoConsulta.valor']}" style="font-weight:bold" for="valor" styleClass="fmt_label_form_cadastro" />
					</h:panelGroup>					
					<p:inputMask value="#{manterTipoConsultaBean.tipoConsulta.valorConsulta}" size="10" mask="?99.99" label="valor" required="true" id="valor" style="border: solid 1px #5FA03F;background-color: #FFF;" styleClass="fmt_input_form_cadastro" />					
					<h:outputText />
					<h:message for="valor" id="msgValor" styleClass="msg_erro_required"/>
				</h:panelGrid>
				<h:panelGroup style="padding-top: 20px;padding-bottom:10px;text-align:center" layout="block">
					<p:commandButton value="#{msg['display.view.adm.salvar']}" action="#{manterTipoConsultaBean.editar}" oncomplete="if(document.getElementById('valor').value.length != 0){editar.hide()}" update="pnl_edit, table_tipoConsulta"/>
					<p:commandButton value="#{msg['display.view.adm.cancelar']}" oncomplete="editar.hide()"/>
				</h:panelGroup>
			</h:form>
	    </p:dialog>
	    
		<p:dialog header="Cadastrar" widgetVar="cadastrar" resizable="false" modal="true" width="450" showEffect="clip" hideEffect="fold">
			<h:form prependId="false">
				<h:panelGrid columns="2" cellpadding="2" cellspacing="0" id="pnl_cadastro">
					<h:panelGroup>
						<span class="campoObrigatorio">*</span>
						<h:outputLabel value="#{msg['display.label.tipoConsulta.nome']}" style="font-weight:bold" for="tipoConsultaCad" styleClass="fmt_label_form_cadastro" />
					</h:panelGroup>					
					<p:inputText value="#{manterTipoConsultaBean.tipoConsulta.tipoConsulta}" size="50" maxlength="50" label="tipo consulta" required="true" id="tipoConsultaCad" style="border: solid 1px #5FA03F;background-color: #FFF;" styleClass="fmt_input_form_cadastro" />
					<h:outputText />
					<h:message for="tipoConsultaCad" id="msgTipoConsultaCad" styleClass="msg_erro_required"/>
					
					<h:panelGroup>
						<span class="campoObrigatorio">*</span>
						<h:outputLabel value="#{msg['display.label.tipoConsulta.valor']}" style="font-weight:bold" for="valorCad" styleClass="fmt_label_form_cadastro" />
					</h:panelGroup>					
					<p:inputMask value="#{manterTipoConsultaBean.tipoConsulta.valorConsulta}" size="10" mask="?99.99" label="valor" required="true" id="valorCad" style="border: solid 1px #5FA03F;background-color: #FFF;" styleClass="fmt_input_form_cadastro" />
					<h:outputText />
					<h:message for="valorCad" id="msgValorCad" styleClass="msg_erro_required"/>
				</h:panelGrid>
				<h:panelGroup style="padding-top: 20px;padding-bottom:10px;text-align:center" layout="block">
					<p:commandButton value="#{msg['display.view.adm.salvar']}" action="#{manterTipoConsultaBean.cadastrar}" 
									 oncomplete="if(document.getElementById('tipoConsultaCad').value.length == 0){
													return;
												}
									 			if(document.getElementById('valorCad').value.length == 0){
													return;
												}
												else{
													cadastrar.hide();
												}" update="pnl_cadastro, table_tipoConsulta"/>
					<p:commandButton value="#{msg['display.view.adm.cancelar']}" onclick="cadastrar.hide()"/>
				</h:panelGroup>
			</h:form>
	    </p:dialog>
		
	</ui:define>
</ui:composition>